%% Saving and Loading Files

%'save' and 'load' save matlab variable in a *.mat file

%This saves everything currently in workspace
save('Allvars')
clear all

%This loads them back.  Carefull- it will overwrite existing variables
load('Allvars')

%Insted load them in as a structure
vars=load('Allvars')

%save just the variable 'A'
save('Allvars_A','A')
clear all
load('Allvars_A')

clear all

%load just 'A'
load('Allvars','A')

%Carefull with objects, the class definition file must be available. 
NI=NIntegrate()
save('NItest','NI')
clear all
load('NItest','NI')


%Some nice GUI's for getting file names and paths
[fn fdir]=uigetfile()

[fn fdir]=uiputfile()

%Save a matrix to a comma seperated value file format
A=rand(10,3)
csvwrite('testcsv.csv',A)

%Load in a *.csv file. 
[fn fdir]=uigetfile()
fnall=fullfile(fdir,fn)
B=csvread(fnall)
































